﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WorldDomination.Net;
using CostaRicaPureTravelUtils.log;

namespace CostaRicaPureTravelUtils.location
{
    public class RemoteClientLocation
    {
        public static string getClientLocation(string remoteAddr) 
        {
            string country = String.Empty;
            IPAddress ipAddress;
            try
            {
                if (IPAddress.TryParse(remoteAddr, out ipAddress))
                {
                    country = ipAddress.Country(); // return value: UNITED STATES
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Location client", ex);
            }
            return country;
        }
    }
}
